package com.neuedu.hcp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.hcp.entity.RecoveryPlan;
import com.neuedu.hcp.entity.RespPageBean;
import com.neuedu.hcp.mapper.RecoveryPlanMapper;
import com.neuedu.hcp.service.IRecoveryPlanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 第八组
 * @since 2021-04-26
 */
@Service
public class RecoveryPlanServiceImpl extends ServiceImpl<RecoveryPlanMapper, RecoveryPlan> implements IRecoveryPlanService {

    @Autowired
    private RecoveryPlanMapper recoveryPlanMapper;
    /**
     * 获取所有康复计划（分页）
     * @param currentPage
     * @param size
     * @param recoveryPlan
     * @return
     */

    @Override
    public RespPageBean getPlanListByPage(Integer currentPage, Integer size, RecoveryPlan recoveryPlan) {
        Page<RecoveryPlan> page = new Page<>(currentPage,size);
        IPage<RecoveryPlan> recoveryPlanByPage =recoveryPlanMapper.getPlanListByPage(page,recoveryPlan);
        RespPageBean respPageBean = new RespPageBean(recoveryPlanByPage.getTotal(),recoveryPlanByPage.getRecords());
        return respPageBean;
    }

    @Override
    public int insert(RecoveryPlan recoveryPlan) {
        return recoveryPlanMapper.insert(recoveryPlan);
    }
}
